<div class="row">
<div class="col-xs-12">
<form action="<?php echo DOMAIN_ADMIN?>/navigation/edit" method="post"  id='add_user_submit'>
	<input type="hidden" name="id" value="<?php echo $navigation_id; ?>" id="data-permissions-edit-id">
    <table id="inputs-table" class="table table-striped table-bordered table-hover" >
    	<tr>
    
    		<td width="100" align="right"><nobr>
    				<strong class="red">*</strong> 导航名称：
    			</nobr></td>
    		<td>
    			<input type="text" name="name"  id="data-role-name"
    				   value="<?php echo $name;?>" style="width: 30%" maxlength="20">
    			<label class="red" id="data-role-name-error"><?php echo form_error('name')?></label>
    		</td>
    	</tr>
    
    
    	<tr>
    
    		<td width="100" align="right"><nobr>
    				链接地址：
    			</nobr></td>
    		<td>
    			<input type="text" name="link"
    				   value="<?php echo $link;?>" style="width: 30%"  >
    			<span class="red" style="display: inline"><?php echo form_error('link')?></span>
    		</td>
    	</tr>
    
    	<tr>
    
    		<td width="100" align="right"><nobr>
    				<strong class="red">*</strong>父级操作：
    			</nobr></td>
    		<td>
    			<select name="pid">
    				<option value="0">顶级</option>
    				<?php if(!empty($top_permissions)) {?>
    					<?php foreach($top_permissions as $val){ ?>
    						<option value="<?php echo $val['id']?>" <?php if($pid==$val['id']){ ?> selected="selected" <?php } ?>
    							><?php echo $val["name"]?></option>
    					<?php }  }?>
    
    			</select>
    		</td>
    	</tr>
    
    	<tr>
    
    		<td width="100" align="right"><nobr>
    				<strong class="red"></strong> 排序：
    			</nobr></td>
    		<td>
    			<input type="text" name="orderby" value="<?php echo $orderby;?>" style="width: 30%">
    
    		</td>
    	</tr>
    
    	
    	<tr>
    		<td colspan="2" align="center">
    			<button class="btn btn-info btn-sm" type="submit">提交</button>
    			&nbsp;&nbsp;
    			<button class="btn btn-sm" type="button" onclick="window.history.back(-1);">取消</button>
    
    		</td>
    	</tr>
    </table>
</form>
</div>
</div>

<script type="text/javascript">

	$(document).on('keyup', '#data-role-name', function () {

		var navigation_name=$('#data-role-name').val();
		var navigation_id=$('#data-permissions-edit-id').val();
		var url='<?php echo DOMAIN_MAIN?>/api/permissions/check_navigation_name';
		var params={
			navigation_name:navigation_name,
			navigation_id:navigation_id
		};

		$.get(url, params, function (data) {
			if(data.state=='success'){
				var new_dom='导航名称已存在，请重新填写！';
				$("#data-role-name-error").html(new_dom);
				return false;
			}else{
				$("#data-role-name-error").html('');
				return true;
			}

		},'json');

	});
</script>
